/**
*      author: Y_Yao
*      created: 2024-12-04 10:44:55
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 65 + 7;
int a[N],h[N],b[N];
int n;
int sum,maxlen,minlen = INF;
int indx = 1;

void dfs(int len,int cur,int step,int next)
{
    if(step == n)
    {
        cout << len << endl;
        exit(0);
    }

    if(cur == len)
    {
        cur = 0;
        next = maxlen;
    }

    for(int i = next;i >= minlen;i--)
    {
        if(!h[i]) continue;
        h[i]--;
        dfs(len,cur + i,step + 1,min(len - (cur + i),i));
        h[i]++;
        if(cur == 0 || cur + i == len) break;
    }
}

void solve()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        h[a[i]]++;
        maxlen = max(maxlen,a[i]);
        minlen = min(minlen,a[i]);
        sum += a[i];
    }

    for(int i = maxlen ;i <= sum / 2;i++)
    {
        if(sum % i == 0) b[indx++] = i;
        //cout << b[indx - 1] << endl;
    } 

    for(int i = 1;i <= indx;i++)
    {
        dfs(b[i],0,0,maxlen);
    }
    cout << sum << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}